/*
 * Created on Mar 30, 2010 by Eng. Julian Rousselot
 *  
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
 
package ar.com.visualAORE.view;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JColorChooser;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import ar.com.visualAORE.controller.ColorChooserController;
import ar.com.visualAORE.framework.model.Model;



public class ColorChooser extends JFrame implements ChangeListener {

    protected JColorChooser tcc;
    
   	private JTextField patternName;
    private JButton patternButton;
    
   	private Container container;
    private ColorChooserController controller;
    private JTextField txtConcern;
    
    public ColorChooser(JTextField txtConcern, Model model) {
    	this.controller = new ColorChooserController(this, model);
    	this.txtConcern = txtConcern;
    	createAndShowGUI();
    }

    public void stateChanged(ChangeEvent e) {
        Color newColor = tcc.getColor();
    }

    private void createAndShowGUI() {
    	container = getContentPane();
    	
    	patternName = new JTextField(txtConcern.getText());
    	patternName.setEditable(false);
        patternButton = new JButton("Add");
        patternButton.addActionListener(controller);
        patternName.setBorder(BorderFactory.createTitledBorder("Concern's Name"));
        tcc = new JColorChooser();
        tcc.getSelectionModel().addChangeListener(this);
        tcc.setBorder(BorderFactory.createTitledBorder("Choose Text Color"));
        container.add(patternName, BorderLayout.NORTH);
        container.add(tcc, BorderLayout.CENTER);
        container.add(patternButton, BorderLayout.SOUTH);
    	
       // setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        pack();
        setVisible(true);
		setLocationRelativeTo(null);

    }
    public JColorChooser getTcc() {
		return tcc;
	}

	public JTextField getPatternName() {
		return patternName;
	}
	
	public JButton getPatternButton() {
			return patternButton;
	}

}